/******
*
* material.h: A class representing OpenGL Material
*
* (c) 2000-2004 Xiaoyu Zhang
*
* v 1.1
*
*******/

#ifndef _PBVP_MATERIAL_H
#define _PBVP_MATERIAL_H

#ifdef WIN32
#include <windows.h>
#endif

#ifdef MACX_DEV
#include <gl.h>
#else
#include <GL/gl.h>
#endif

#include "color.h"

namespace PBVP {
class Material {
	
public:
	/// Default Material Constructor	
	Material() 
		: m_Ambient(Color::COLOR_BLACK), m_Diffuse(Color::COLOR_GREEN),
		m_Specular(Color::COLOR_WHITE), m_Emission(Color::COLOR_BLACK)
	{
		m_Shiness = 25;
	}
	
	/// 
	Material(const Color& ambt, const Color& diff, const Color& spec, 
		const Color& emis, float shin)
		:m_Ambient(ambt), m_Diffuse(diff), m_Specular(spec), 
		m_Emission(emis), m_Shiness(shin) 
	{}
	
	Material(const Color& ambt, const Color& diff, const Color& spec, float shin)
		:m_Ambient(ambt), m_Diffuse(diff), m_Specular(spec), m_Shiness(shin) 
	{}
	
	/// Copy constructor
	Material(const Material& m) 
		: m_Ambient(m.m_Ambient), m_Diffuse(m.m_Diffuse), 
		m_Specular(m.m_Specular), m_Emission(m.m_Emission)
	{ m_Shiness = m.m_Shiness;}
	
	/// assignment operator
	Material& operator = (const Material& m);
	
	/// Accessors 
	Color& ambient() {return m_Ambient;}
	const Color& ambient() const {return m_Ambient;}
	void setAmbient(const Color& c) { m_Ambient = c; }

	Color& diffuse() {return m_Diffuse;}
	const Color& diffuse() const {return m_Diffuse;}
	void setDiffuse(const Color& c) { m_Diffuse = c; }

	Color& specular() {return m_Specular;}
	const Color& specular() const {return m_Specular;}
	void setSpecular(const Color& c) {m_Specular = c;}

	Color& emission() {return m_Emission;}
	const Color& emission() const {return m_Emission;}
	void setEmission(const Color& c) { m_Emission = c; }

	float& shiness() {return m_Shiness;}
	const float& shiness() const {return m_Shiness;}
	void setShiness(float s) { m_Shiness = s; }
	
	///	Apply this material to a given face
	void apply(GLenum face);
	
private:
	Color m_Ambient;
	Color m_Diffuse;
	Color m_Specular;
	Color m_Emission;
	float m_Shiness;
};
}
#endif
